import requests


# s = requests.Session()
# s.auth('admin', 'admin123')

def jwt_response_payload_handler(token, user=None, request=None):
    """
    :param token:
    :param user:
    :param request:
    :return: code:
    """
    return {
        'code': 2000,
        'token': token,
        'name': user.username,
        'id': user.id
    }


def sort_list(target_list):
    n = len(target_list)
    for i in range(n - 1):
        for j in range(n - 1 - i):
            if target_list[j] > target_list[j + 1]:
                target_list[j], target_list[j + 1] = target_list[j + 1], target_list[j]


def operate_file(file_name):
    with open(file_name, 'w') as f:
        f.write('hello')


def catch_except(func):
    def wrapper(self, *args, **kwargs):
        try:
            print('======')
            if args:
                print('请求参数：{}'.format(args[0]))
            return func(self, *args, **kwargs)
        except Exception as e:
            print(e)
            self.session.close()

    return wrapper


if __name__ == '__main__':
    # operate_file('test.txt')
    # ft = open('test.txt', 'r')
    # for f in ft.readlines():
    #     print(f)
    a = getattr(jwt_response_payload_handler, '__doc__')
    b = a.split('\n')
    print(b)
    for i in b:
        if ':return:' in i:
            print(i)
    # str1 = ':return '
    # print(a[a.index(str1):])
